package org.point.dao.impl;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import org.point.common.dao.impl.BaseDaoImpl;
import org.point.common.util.DoPage;
import org.point.dao.DeliveryInfoDao;
import org.point.dao.UserLoginDao;
import org.point.dao.UsersDao;
import org.point.domain.ConvertRuleDetail;
import org.point.domain.DeliveryInfo;
import org.point.domain.ProductType;
import org.point.domain.UserLogin;
import org.point.domain.Users;
import org.springframework.stereotype.Repository;

/**
 * 
 * @ClassName: ConvertRuleDetailDaoImpl  
 * @Description: TODO(兑换规则明细数据实现类)  
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午3:28:17  
 *
 */
@Repository("UsersDao")
public class UsersDaoImpl extends BaseDaoImpl<Users, Serializable> implements UsersDao {

	public static final String SQLID_SEARCHUSERS = "search_users";
	
	public static final String SQLID_SEARCHCOUNTUSERS = "search_count_users";

	private static final String SQLID_INSERUSERS = "insert";

	private static final String SQLID_UPDATEUSERS = "updateByPrimaryKeySelective";

	private static final String SQLID_SEARCHFORUSERSPAGE = "search_For_Users_page";

	private static final String SQLID_SEARCHFORUSERSCOUNT = "search_For_Users_count";

	private static final String SQLID_SEARCHALLUSERS = "searchAllUsers";

	
	/**
	 * 利用反射，获取mapper.xml的namespace
	 * <p>Title: </p>  
	 * <p>Description: </p>
	 */
	public UsersDaoImpl() {
		namespace = super.getNamespace();
	}

	public List<Users> searchUsers(Map<String, Object> map) {
		List<Users> users = getSqlSession().selectList(SQLID_SEARCHUSERS);
		return users;
	}

	public Integer searchCountByUsers(Map<String, Object> map) {
		List<Users> users = getSqlSession().selectList(SQLID_SEARCHUSERS);
		return users.size();
	}

	public Integer insertUsers(Users record) {
		Integer result = getSqlSession().insert(namespace + SQLID_INSERUSERS, record);
		return result;
	}

	public Integer updateUsers(Users record) {
		Integer result = getSqlSession().update(namespace + SQLID_UPDATEUSERS, record);
		return result;
	}

	public List<Users> searchForUsers(DoPage<Users> page) {
		List<Users> records = null;
		try {
			records = getSqlSession().selectList(namespace + SQLID_SEARCHFORUSERSPAGE, page);
		} catch (Exception e) {
			throw new RuntimeException("查询数据总记录数错误！", e);
		}
		return records;
	}

	public Integer searchForUsersCount(DoPage<Users> page) {
		Integer result = 0;
		try {
			result = getSqlSession().selectOne(namespace + SQLID_SEARCHFORUSERSCOUNT, page);
		} catch (Exception e) {
			throw new RuntimeException("查询数据总记录数错误！", e);
		}
		return result;
	}

	public List<Hashtable<Object, Object>> selectAllUsers() {
		List<Hashtable<Object, Object>> record = null;
		try {
			record = getSqlSession().selectList(namespace+SQLID_SEARCHALLUSERS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return record;
	}
}
